package high.concurrent.pay.strategypattern.payCreate;

import high.concurrent.pay.service.PayService;
import high.concurrent.vo.PayInfoVO;
import org.apache.http.client.methods.CloseableHttpResponse;

/**
 * 支付策略模式
 */
public class PayContext {

    private PayService payService;

    public PayContext(PayService payService){

        this.payService = payService;
    }

    /**
     * 统一下单
     * @param payInfoVO
     * @return
     */
    public CloseableHttpResponse createOrder(PayInfoVO payInfoVO){
        CloseableHttpResponse closeableHttpResponse = payService.createOrder(payInfoVO);
        return closeableHttpResponse;
    }

    /**
     * 查询订单状态
     * @param payInfoVO
     * @return
     */
    public CloseableHttpResponse selectOrderStatus(PayInfoVO payInfoVO){
        CloseableHttpResponse closeableHttpResponse = payService.selectOrderStatus(payInfoVO);
        return closeableHttpResponse;
    }

    /**
     * 订单关闭
     * @param payInfoVO
     * @return
     */
    public CloseableHttpResponse closeOrder(PayInfoVO payInfoVO){
        CloseableHttpResponse closeableHttpResponse = payService.closeOrder(payInfoVO);
        return closeableHttpResponse;
    }


    /**
     * 订单退款
     * @param payInfoVO
     * @return
     */
    public CloseableHttpResponse refundOrder(PayInfoVO payInfoVO){
        CloseableHttpResponse closeableHttpResponse = payService.refundOrder(payInfoVO);
        return closeableHttpResponse;
    }

    /**
     * 退款状态查询
     * @param payInfoVO
     * @return
     */
    public CloseableHttpResponse selectRefundOrderStatus(PayInfoVO payInfoVO){
        CloseableHttpResponse closeableHttpResponse = payService.selectRefundOrderStatus(payInfoVO);
        return closeableHttpResponse;
    }
}
